package com.konne.nightmare.FastPublicOpinion.widget;

import android.content.Context;
import android.graphics.Canvas;
import android.graphics.LinearGradient;
import android.graphics.Paint;
import android.graphics.Path;
import android.graphics.RectF;
import android.graphics.Shader;
import android.util.AttributeSet;
import android.view.View;

import androidx.annotation.Nullable;

import com.blankj.utilcode.util.SizeUtils;

/**
 * Create by ws.
 * on Data:2022/1/26  Time:下午 5:34.
 * description: ** .
 */
public class CGMenuView extends View {
    private Paint mPaint;
    private Path path;
    public CGMenuView(Context context) {
        this(context,null);
    }

    public CGMenuView(Context context, @Nullable AttributeSet attrs) {
        this(context, attrs,0);
    }

    public CGMenuView(Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
        mPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
        mPaint.setFilterBitmap(true);
        mPaint.setDither(true);
        mPaint.setAntiAlias(true);
        mPaint.setStyle(Paint.Style.STROKE);
        mPaint.setStrokeCap(Paint.Cap.ROUND);
        path=new Path();
    }

    @Override
    protected void onDraw(Canvas canvas) {
        super.onDraw(canvas);
        float strokeWidth=SizeUtils.dp2px(90);
       // RectF rectF=new RectF(strokeWidth/2,strokeWidth/2,getWidth()*2-strokeWidth/2,getHeight()*2-strokeWidth/2);

        LinearGradient mShader = new LinearGradient(0,0, 0,getHeight(), 0xffFDFDFF, 0xffC3DAF1, Shader.TileMode.CLAMP);
        mPaint.setStrokeWidth(strokeWidth);
        mPaint.setShader(mShader);
       // canvas.drawArc(rectF,195,60,false,mPaint);
        path.close();
        path.moveTo(strokeWidth/2,getHeight()-strokeWidth/2);
        //path.arcTo(rectF,195,60);
        path.quadTo(strokeWidth/2+SizeUtils.dp2px(5),strokeWidth/2+SizeUtils.dp2px(5),getWidth()-strokeWidth/2-SizeUtils.dp2px(2),strokeWidth/2);
        canvas.drawPath(path,mPaint);
    }
}
